package com.xintai.caiwu.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xintai.common.annotation.Log;
import com.xintai.common.core.controller.BaseController;
import com.xintai.common.core.domain.AjaxResult;
import com.xintai.common.enums.BusinessType;
import com.xintai.caiwu.domain.ErpClientmoney;
import com.xintai.caiwu.service.IErpClientmoneyService;
import com.xintai.common.utils.poi.ExcelUtil;
import com.xintai.common.core.page.TableDataInfo;

/**
 * 客户余额Controller
 * 
 * @author xintai
 * @date 2021-01-12
 */
@RestController
@RequestMapping("/caiwu/clientmoney")
public class ErpClientmoneyController extends BaseController
{
    @Autowired
    private IErpClientmoneyService erpClientmoneyService;

    /**
     * 查询客户余额列表
     */
    @PreAuthorize("@ss.hasPermi('caiwu:clientmoney:list')")
    @GetMapping("/list")
    public TableDataInfo list(ErpClientmoney erpClientmoney)
    {
        startPage();
        List<ErpClientmoney> list = erpClientmoneyService.selectErpClientmoneyList(erpClientmoney);
        return getDataTable(list);
    }

    /**
     * 导出客户余额列表
     */
    @PreAuthorize("@ss.hasPermi('caiwu:clientmoney:export')")
    @Log(title = "客户余额", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ErpClientmoney erpClientmoney)
    {
        List<ErpClientmoney> list = erpClientmoneyService.selectErpClientmoneyList(erpClientmoney);
        ExcelUtil<ErpClientmoney> util = new ExcelUtil<ErpClientmoney>(ErpClientmoney.class);
        return util.exportExcel(list, "clientmoney");
    }

    /**
     * 获取客户余额详细信息
     */
    @PreAuthorize("@ss.hasPermi('caiwu:clientmoney:query')")
    @GetMapping(value = "/{cmId}")
    public AjaxResult getInfo(@PathVariable("cmId") Long cmId)
    {
        return AjaxResult.success(erpClientmoneyService.selectErpClientmoneyById(cmId));
    }

    /**
     * 新增客户余额
     */
    @PreAuthorize("@ss.hasPermi('caiwu:clientmoney:add')")
    @Log(title = "客户余额", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ErpClientmoney erpClientmoney)
    {
        return toAjax(erpClientmoneyService.insertErpClientmoney(erpClientmoney));
    }

    /**
     * 修改客户余额
     */
    @PreAuthorize("@ss.hasPermi('caiwu:clientmoney:edit')")
    @Log(title = "客户余额", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ErpClientmoney erpClientmoney)
    {
        return toAjax(erpClientmoneyService.updateErpClientmoney(erpClientmoney));
    }

    /**
     * 删除客户余额
     */
    @PreAuthorize("@ss.hasPermi('caiwu:clientmoney:remove')")
    @Log(title = "客户余额", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cmIds}")
    public AjaxResult remove(@PathVariable Long[] cmIds)
    {
        return toAjax(erpClientmoneyService.deleteErpClientmoneyByIds(cmIds));
    }
}
